package cn.virens.common.util.components.pool;

import org.apache.commons.pool2.DestroyMode;
import org.apache.commons.pool2.PooledObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class VirObjectPoolFactoryBase<K, V> implements VirObjectPoolFactory<K, V> {
    protected final Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public boolean validateObject(K key, PooledObject<V> value) {
        return true;
    }

    @Override
    public void activateObject(K key, PooledObject<V> value) throws Exception {
        logger.debug("activateObject:{}->{}", key, value);
    }

    @Override
    public void passivateObject(K key, PooledObject<V> value) throws Exception {
        logger.debug("passivateObject:{}->{}", key, value);
    }

    @Override
    public void destroyObject(K key, PooledObject<V> value, DestroyMode mode) throws Exception {
        logger.debug("destroyObject:{}({})->{}", key, mode, value);
    }
}
